import { ARFactory } from '../axios_conf'
// eslint-disable-next-line
import { Method } from 'axios'

/**
 * 获取会员组
 * @param {number} page 当前页数
 * @param {number} _result 返回条目
 * @returns {Promise}
 */
function fetchVips(config = { page: 1, _result: 15 }, method = 'GET') {
  const url = 'vips'
  return ARFactory({ url, method, params: config })
}

/**
 * 获取单个会员
 * @param {{ uid }} config 用户uid
 * @returns {Promise}
 */
function fetchVip(config = { uid }, method = 'GET') {
  const url = 'vip'
  return ARFactory({ url, method, params: config })
}

/**
 * 模糊搜索会员用户
 * @param {{ keyword }} config 搜索关键字
 * @param {Method} method 请求方式
 * @returns {Promise}
 */
function fuzzyVips(config = { keyword }, method = 'GET') {
  const url = 'fuzzyVips'
  return ARFactory({ url, method, params: config })
}

export { fetchVips, fetchVip, fuzzyVips }
